package leetcode;

public class a563二叉树的坡度 {
    int sum=0;

    public int findTilt(TreeNode root) {
        if (root==null) return 0;
        suborder(root);
        return sum;

    }
    public int suborder(TreeNode root){
        if(root==null) return 0;


        int L=suborder(root.left);
        int R=suborder(root.right);
        sum+=Math.abs(L-R);

        return L+R+root.val;



    }
}
